package com.suixun.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.suixun.dao.HomeModuleMapper;
import com.suixun.entity.HomeModule;
import com.suixun.entity.HomeModuleExample;
import com.suixun.service.HomeModuleService;
import com.suixun.util.SuixunAssert;
@Service
public class HomeModuleServiceImpl implements HomeModuleService{

	@Autowired
	private HomeModuleMapper homeModuleMapper;
	
	@Override
	public void save(HomeModule homeModule) {
		
		SuixunAssert.assertNull(homeModule, "参数不能为空！");
		SuixunAssert.assertNull(homeModule.getTitle(), "标题不能为空！");
		SuixunAssert.assertNull(homeModule.getCode(), "code不能为空！");
		
		homeModuleMapper.insert(homeModule);
	}

	@Override
	public void del(Integer id) {
		
		SuixunAssert.assertNull(id, "参数不能为空！");
		
		homeModuleMapper.deleteByPrimaryKey(id);
	}

	@Override
	public void update(HomeModule homeModule) {
		
		SuixunAssert.assertNull(homeModule, "参数不能为空！");
		SuixunAssert.assertNull(homeModule.getId(), "id不能为空！");
		SuixunAssert.assertNull(homeModule.getTitle(), "标题不能为空！");
		SuixunAssert.assertNull(homeModule.getCode(), "code不能为空！");
		
		homeModuleMapper.updateByPrimaryKey(homeModule);
	}

	@Override
	public HomeModule get(Integer id) {
		
		SuixunAssert.assertNull(id, "参数不能为空！");
		return homeModuleMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<HomeModule> listHomeModule() {
		
		HomeModuleExample example = new HomeModuleExample();
		return homeModuleMapper.selectByExample(example);
	}

	
}
